#pragma once

#include "stdafx.h"

//+------------------------------------------------------------------+
//	Most globals are initialized once, and then basically read only.
//	Could also be turned into a class, but wouldn't be too helpful.
namespace PTT
{
	extern	std::vector<
				std::vector<OsuFile*> >			OsuFiles;		// Parsed osu files

	extern	std::vector<std::wstring>		SongNames;		// artist + name of songs

	extern	Index									NameIndex;		// Alphabetical index of "SongNames"

	extern	Window3D								*wnd;

	extern	Audio									*audio;

	extern	std::wstring						DrumFiles[4];
	extern	MediaFile							*drum[4];
	extern	Texture								*texCursor;
	extern	GraphicsFile						*defaultBG;

	extern	const TiledTexture				*NumbersSmall,
														*NumbersBig,
														*FixedFont,
														*Symbols,
														*Bubble,
														*SunFlare,
														*Buttons1,
														*Buttons2;

//----
//	This song gets selected during "SelectSong", is used by "PreviewThread", and finally can be played with "PlaySong"
//	SetHighscore and GetHighscore also apply to this song.
	extern	const OsuFile						*SelectedSong;
	extern	bool									BonusMode;
	extern	double								Quality;			// map quality during optimization, 100 is considered good, but it can be higher.
	extern	bool									UseAudio;		// false, if the audio initialization failed.

//----
//	global variables, initialized from "config.ini"
	extern	bool									Fullscreen;
	extern	int									MasterVolume,
														SongVolume,
														EffectsVolume[4];
	extern	std::wstring						SongsDir;		// osu songs folder

	extern	DWORD									VK_BUTTONS[4];	// VK key codes for the 4 buttons

//----
//	histogram of all errors and the current mode, the offset into the array is 512,
//	so for example if ms_error_count[512] is the maximum value than ms_error_mode = 0.
	extern	DWORD									ms_error_count[1024];
	extern	double								ms_error_mode;

//+------------------------------------------------------------------+
	struct	Header
	{
				enum ID { PTT_ = 0x20545450 };
				DWORD id,						//	"PTT "
				version,							// header version
				sizeHighscores,				// Highscores table size in bytes
				reserved[5];
	};

//+------------------------------------------------------------------+
	struct	HighscoreEntry
	{
				DWORD	key, score1, score2, great;
	};

//+------------------------------------------------------------------+
	extern	std::vector<HighscoreEntry>	Highscores;		// highscore table


//+------------------------------------------------------------------+
	void InitGlobals();
	void DeleteGlobals();

//+------------------------------------------------------------------+
	void	SetHighscore(DWORD score, bool great, bool perfect);
	void	GetHighscore(DWORD &score1, DWORD &score2, DWORD *great = NULL);
	bool	GetPerfect();

//+------------------------------------------------------------------+
	void	SaveButtons();
	void	SaveErrors();

}//namespace PTT


